<?php
   
/**
 * Mapper for tmimetypes
 * 
 * @author Martin Grossmann <snake.aas@gmail.com>
 * @version 1.0
 * @package Mappers
 *
 * @property string $Name List of supported Mime Types. 50 chars max
 * @property string $Description Short description. 255 chars max
 * @property string $Extension Extension of image type. 5 chars max
 * 
 * @entity
 * @table(name="tmimetypes")
 */     
class MimeType {
  /**
   * List of supported Mime Types
   * 
   * @access private
   * @var string
   * 
   * @Id
   * @column(name="Mime", type="string", length=50)
   */
   private $mime;
     
  /**
   * Short description
   * 
   * @access private
   * @var string
   * 
   * @column(name="Description", type="string", length=255, nullable=true)
   */
   private $description;
     
  /**
   * Extension of image type
   * 
   * @access private
   * @var string
   * 
   * @column(name="Extension", type="string", length=5)
   */
   private $extension;
     

  public function __get($name) {
  
    switch($name) {
      case "Name": 
        return $this->mime;
        break;
    
      case "Description": 
        return $this->description;
        break;
      
      case "Extension": 
        return $this->extension;
        break;
      
      default: 
        throw new EntityException(sprintf(T_("Trying to get undefined property")." ", $name));
    }
  }
  
  public function __set($name, $value) {

    switch($name) {
      case "Name": 
        $this->mime = Validations::validateString($value, 50, null, false);
        break; 

      case "Description": 
        $this->description = Validations::validateString($value, 255, null, true);
        break; 

      case "Extension": 
        $this->extension = Validations::validateString($value, 5, null, false);
        break; 

      default: 
        throw new EntityException(sprintf(T_("Trying to set undefined property")." ", $name));
    }
  }  
  
  public function __construct() {
    
  }
  
}